package core.tests;

import org.junit.Test;

import core.exceptions.ExceptionFormat;
import core.exceptions.SemanticException;
import core.tests.resquests.SyntacticSemanticRequest;

public class SemanticTests {

	@Test
	public void duplicatedImportTest() {
		SemanticException expectedException = new SemanticException(
				ExceptionFormat.DUPLICATED_IMPORT, 3, 54, "WriteString", 3, 22);

		new SyntacticSemanticRequest("3.2 Semantically Wrong Input.mod")
				.analyze(expectedException);
	}
	
	@Test
	public void duplicatedModuleVariableTest() {
		SemanticException expectedException = new SemanticException(
				ExceptionFormat.DUPLICATED_VARIABLE, 5, 5, "Stuff", 3, 5);

		new SyntacticSemanticRequest("3.3 Semantically Wrong Input.mod")
				.analyze(expectedException);
	}

	@Test
	public void duplicatedProcedureVariableTest() {
		SemanticException expectedException = new SemanticException(
				ExceptionFormat.DUPLICATED_VARIABLE, 6, 24, "Puppy", 5, 24);

		new SyntacticSemanticRequest("3.4 Semantically Wrong Input.mod")
				.analyze(expectedException);
	}

	@Test
	public void duplicatedProcedureTest() {
		SemanticException expectedException = new SemanticException(
				ExceptionFormat.DUPLICATED_PROCEDURE, 19, 11, "PrintDataOut", 5, 11);

		new SyntacticSemanticRequest("3.5 Semantically Wrong Input.mod")
				.analyze(expectedException);
	}
	
	@Test
	public void notDeclaredModuleVariableTest() {
		SemanticException expectedException = new SemanticException(
				ExceptionFormat.UNDECLARED_VARIABLE_PROCEDURE, "Stuff", 4, 5);

		new SyntacticSemanticRequest("3.6 Semantically Wrong Input.mod")
				.analyze(expectedException);
	}
	
	@Test
	public void notDeclaredProcedureVariableTest() {
		SemanticException expectedException = new SemanticException(
				ExceptionFormat.UNDECLARED_VARIABLE_PROCEDURE, "Puppy", 7, 14);

		new SyntacticSemanticRequest("3.7 Semantically Wrong Input.mod")
				.analyze(expectedException);
	}
	
	@Test
	//TODO VERIFICAR, TÁ ERRADO
	public void notDeclaredProcedureTest() {
		SemanticException expectedException = new SemanticException(
				ExceptionFormat.UNDECLARED_VARIABLE_PROCEDURE, "PrintDataOut", 4, 5);

		new SyntacticSemanticRequest("3.8 Semantically Wrong Input.mod");
	}
	
	@Test
	public void cannotApplyNotOperationTest() {
		SemanticException expectedException = new SemanticException(
				ExceptionFormat.CANNOT_APPLY_NOT_OPERATION, 8, 18);

		new SyntacticSemanticRequest("3.9 Semantically Wrong Input.mod").analyze(expectedException);
	}
	
	@Test
	public void incompatibleAssignmentTest() {
		SemanticException expectedException = new SemanticException(
				ExceptionFormat.INCOMPATIBLE_ASSIGNMENT, "BOOLEAN", "CHAR", 8, 5, 8, 18);

		new SyntacticSemanticRequest("3.10 Semantically Wrong Input.mod").analyze(expectedException);
	}
	
	@Test
	public void incompatibleExpressionsRelationalOperationTest() {
		SemanticException expectedException = new SemanticException(
				ExceptionFormat.INCOMPATIBLE_EXPRESSIONS, 8, 18, 8, 25);

		new SyntacticSemanticRequest("3.11 Semantically Wrong Input.mod").analyze(expectedException);
	}

}
